package com.cake.base.util;

import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * 获取application中的配置
 * @author TroubleMan
 *
 */

@Configuration
public class PropertiesUtils implements EnvironmentAware{
	
	private static RelaxedPropertyResolver propertyResolver;
    
    /**
     * 获取配置
     * @param name
     * @return
     */
    public static String getProperties(String name){
    	return propertyResolver.getProperty(name);
    }

	@Override
	public void setEnvironment(Environment env) {
        propertyResolver = new RelaxedPropertyResolver(env, "cake.");
	}
}
